package com.sikao.app.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.sikao.app.R;

import java.util.List;

/**
 * Created by Administrator on 2016/8/12.
 */
public class PicturesAdapter extends BaseAdapter {

	private Context context;
	private ImageLoader imageLoader;
	private List<String> beans;

	public PicturesAdapter(Context context, List<String> beans) {
		this.context = context;
		this.beans = beans;
		imageLoader = ImageLoader.getInstance();
	}

	@Override
	public int getCount() {
		return beans.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = View.inflate(context, R.layout.pictures_list_item, null);
			convertView.setTag(new ViewHolder(convertView));
		}
		ViewHolder viewHolder = (ViewHolder) convertView.getTag();
		imageLoader.displayImage(beans.get(position),viewHolder.iv);
		return convertView;
	}

	public class ViewHolder {
		public final ImageView iv;
		public final View root;

		public ViewHolder(View root) {
			iv = (ImageView) root.findViewById(R.id.iv);
			this.root = root;
		}
	}
}
